package irobot

//
//import (
//	"fmt"
//	"github.com/go-vgo/robotgo"
//	"github.com/kbinani/screenshot"
//	hook "github.com/robotn/gohook"
//	"image"
//	"runtime"
//	images "walis-vue3/server/common/kits/image"
//	ijson "walis-vue3/server/common/kits/json"
//	istring "walis-vue3/server/common/kits/strings"
//)
//
//// Capture2Clipboard https://blog.csdn.net/iamdi/article/details/107743934
//// 截图保存到剪贴板
//func Capture2Clipboard() {
//	sys := runtime.GOOS
//	if istring.EqualsIgnoreCase(sys, "darwin") {
//		CaptureDarwin()
//	}
//}
//
//type CaptureArea struct {
//	StartX, StartY, EndX, EndY int16
//}
//
//func CaptureDarwin() CaptureArea {
//	defer func() {
//		undefined := recover()
//		if undefined != nil {
//			println(ijson.ToJsonStringIgnoreError(undefined))
//		}
//	}()
//	// 调用屏幕截屏程序(control+shift+command+4)
//	// https://baijiahao.baidu.com/s?id=1711025071165491497&wfr=spider&for=pc
//	//ok := robotgo.AddEvents("4", "ctrl", "shift", "command")
//	ok := robotgo.KeyTap("4", "control", "shift", "command")
//	println(ok)
//
//	// 监听鼠标事件
//	area := CaptureArea{}
//	addMouseListener(&area)
//	return area
//}
//
//func CaptureWindows() CaptureArea {
//	// 调用屏幕截屏程序(control+shift+command+4)
//	// https://baijiahao.baidu.com/s?id=1711025071165491497&wfr=spider&for=pc
//	//ok := robotgo.AddEvents("4", "ctrl", "shift", "command")
//	tapResult := robotgo.KeyTap("S", "Win", "shift")
//	fmt.Println("KeyTap:" + tapResult)
//
//	// 监听鼠标事件
//	area := CaptureArea{}
//	addMouseListener(&area)
//	return area
//}
//
//// MouseListener https://blog.csdn.net/a1309525802/article/details/121879620
//func addMouseListener(area *CaptureArea) {
//	started := false
//	robotgo.EventHook(hook.MouseDown, []string{}, func(ev hook.Event) {
//		// {Kind: MouseDown, Button: 1, X: 616, Y: 439, Clicks: 1}
//		println(ev.String())
//		if started {
//			area.EndX = ev.X
//			area.EndY = ev.Y
//			robotgo.EventEnd()
//		}
//	})
//	robotgo.EventHook(hook.MouseHold, []string{}, func(ev hook.Event) {
//		// {Kind: MouseDown, Button: 1, X: 616, Y: 439, Clicks: 1}
//		println(ev.String())
//		started = true
//		area.StartX = ev.X
//		area.StartY = ev.Y
//	})
//	start := robotgo.EventStart()
//	<-robotgo.EventProcess(start)
//}
//
//func ScreenShot(area CaptureArea, imageFilePath string) {
//	var rect = image.Rect(int(area.StartX), int(area.StartY), int(area.EndX), int(area.EndY))
//	var img *image.RGBA
//	var err error
//	img, err = screenshot.CaptureRect(rect)
//	if err != nil {
//		panic(err)
//	}
//	images.SaveImage(img, imageFilePath)
//}
